<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.GregorianCalendar"%>
<%@ page import="hmg.common.CommonUtils"%>
<%@ page import="java.util.Calendar"%>
<%@ page import="hmg.vo.MainpageVO"%>
<%@ page import="java.util.List"%>
<%-- 
    JSP Name : jspName.jsp
    Description : 설명을 기술합니다.
    author Kim hyung soo
    since 2012. 8. 16.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 8. 16.     Kim hyung soo     최초 생성
--%>
<%
    List<String> validDateList = (List<String>) request.getAttribute("ValidDateList");
    List<MainpageVO> articleList = (List<MainpageVO>) request.getAttribute("ArticleList");
    MainpageVO coverInfo = (MainpageVO) request.getAttribute("CoverInfo");
    String validDateString = (String) request.getAttribute("ValidDateString");

    String year = CommonUtils.getParameter(request.getParameter("year"), "");
    String month = CommonUtils.getParameter(request.getParameter("month"), "");
    String effectDate = CommonUtils.getParameter(request.getParameter("effectDate"), validDateList.get(0));

    Integer currYear = new Integer(coverInfo.getEffectDate().substring(0, 4));
    Integer currMonth = new Integer(coverInfo.getEffectDate().substring(5, 7));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>모터스라인 서브메인 | 현대자동차그룹</title>
<meta name="description" content="현대자동차그룹 사보 모터스라인 소개" />
<meta name="keywords" content="현대자동차그룹 사보, 현대차그룹 사보, 모터스라인" />
<%@ include file="/WEB-INF/jsp/web/kor/include/header.jspf" %>
<script type="text/javaScript">
//<![CDATA[
var year = "<%= currYear %>";
var month = "";
var validDateList = "<%= validDateString %>";

$(document).ready(function(){
    $("#month").html(fn_common_get_valid_month_string(year , validDateList, "<%= effectDate %>"));
});

function fn_select_year() {
    var form = document.MainForm;

    year = form.year.value;
    month = form.month.value;
    
    var effectDate = year + "." + month + ".01";

    $("#month").html(fn_common_get_valid_month_string(year, validDateList, effectDate));
}

function fn_select_month() {
    var form = document.MainForm;
    
    year = form.year.value;
    month = form.month.value;

    if (year == "") {
        alert("연도를 선택해 주세요.");
        document.MainForm.year.focus();
        return;
    }
    
    if (year != "" && month != "") {
        var effectDate = year + "." + month + ".01";
        
        document.location.href = "./MotorsLineSubMain.do?effectDate=" + effectDate;
    }
}

//]]>
</script>
</head>
<body>
    <form id="MainForm" name="MainForm">
        <!--wrap-->
        <div id="wrap">
            <!-- skip navigation -->
            <div id="skipnavition">
                <a href="#gnb">메뉴바로가기</a><a href="#content">본문바로가기</a>
            </div>
            <!--// skip navigation -->

            <hr />

            <!-- header-->
            <%@ include file="/WEB-INF/jsp/web/kor/include/left.jspf" %>
            <!--//header-->
        
            <hr />
        
            <!--container-->
            <div id="container">
                <div class="scroll-pane">   
                    <!-- 공통 -->
                    <div class="subTitle">
                        <div class="pageTitle">
                            <h2><img src="/hmg/images/web/kor/title/group_News_MotorsLine.gif" alt="모터스라인" /></h2>
                            <p class="subCopy"><img src="/hmg/images/web/kor/title/group_News_MotorsLine_desc.gif" alt="현대자동차그룹이 만드는 라이프&amp;컬쳐 매거진" /></p>
                        </div> 
                        <div class="pageLocation">
                            <ul>
                                <li><a href="/hmg/web/kor/Main.do"><img src="/hmg/images/web/kor/common/location_home.gif" alt="홈"/></a></li>
                                <li><a href="/hmg/web/kor/grn/GroupNewsSubMain.do">그룹소식</a></li>
                                <li class="nowPage"><a href="./MotorsLineSubMain.do">모터스라인</a></li>
                            </ul>
                        </div>
                    </div>
                    <!--//공통-->

                    <!--contents-->
                    <div id="content">
                        <div class="groupNews_Btn03">

                            <!-- 130204 추가 -->
                            <div class="left_Btn">
                                <a href="/hmg/web/kor/grn/mtl/MotorsLineList.do?listType=0&page=1"><img src="/hmg/images/web/kor/btn/brn_motorsline.gif" alt="전체보기" /></a>
                            </div>
                            <!-- //130204 추가 -->

                            <div class="right_Btn">
                                <img src="/hmg/images/web/kor/grn/motorsLine_Cover_Select.gif" alt="지난호 보기" />
                                <select id="year" name="year" onchange="javascript:fn_select_year();">
                                    <option value="">년</option>
<%
    Calendar cal = new GregorianCalendar();

    for (int idx = cal.get(Calendar.YEAR); idx >= 2010; idx--) {
        if (idx == currYear)
            out.println("               <option value=\"" + currYear + "\" selected>" + currYear + "</option>");
        else
            out.println("               <option value=\"" + idx + "\">" + idx + "</option>");
    }
%>
                                </select>
                                <select id="month" name="month" onchange="javascript:fn_select_month();">
                                    <option value="">월</option>
                                </select>
                            </div>
                        </div>
                        <!-- 내용 -->

                        <div class="motorsline_Cover" style="background:url('<%= coverInfo.getFilePath() %>') no-repeat left top;width:679px;">
                            <div class="coverTitle">
                                <p><a href="./MotorsLineView.do?listID=<%= articleList.get(0).getListID() %>&listType=0&page=1"><%= articleList.get(0).getTitle() %></a></p>
                            </div>
                            <div class="subList">
                                <dl>
                                    <dt><img src="/hmg/images/web/kor/grn/motorsLine_Cover_List01.gif" alt="Move it" /></dt>
                                    <dd class="firstList">
                                        <ul>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(1).getListID() %>&listType=0&page=1"><%= articleList.get(1).getTitle() %></a></li>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(2).getListID() %>&listType=0&page=1"><%= articleList.get(2).getTitle() %></a></li>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(3).getListID() %>&listType=0&page=1"><%= articleList.get(3).getTitle() %></a></li>
                                        </ul>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt><img src="/hmg/images/web/kor/grn/motorsLine_Cover_List02.gif" alt="Love it" /></dt>
                                    <dd>
                                        <ul>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(4).getListID() %>&listType=0&page=1"><%= articleList.get(4).getTitle() %></a></li>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(5).getListID() %>&listType=0&page=1"><%= articleList.get(5).getTitle() %></a></li>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(6).getListID() %>&listType=0&page=1"><%= articleList.get(6).getTitle() %></a></li>
                                        </ul>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt><img src="/hmg/images/web/kor/grn/motorsLine_Cover_List03.gif" alt="Dream it" /></dt>
                                    <dd>
                                        <ul>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(7).getListID() %>&listType=0&page=1"><%= articleList.get(7).getTitle() %></a></li>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(8).getListID() %>&listType=0&page=1"><%= articleList.get(8).getTitle() %></a></li>
                                            <li><a href="./MotorsLineView.do?listID=<%= articleList.get(9).getListID() %>&listType=0&page=1"><%= articleList.get(9).getTitle() %></a></li>
                                        </ul>
                                    </dd>
                                </dl>
                            </div>
                        </div>
                        <!--// 내용 -->
                    </div>
                    <!--//contents-->
                </div>
            </div>
            <!--//container-->
        
            <hr />
        
            <!--footer-->
            <%@ include file="/WEB-INF/jsp/web/kor/include/footer.jspf" %>
            <!--//footer-->
        
            <hr />
        
            <!--notice-->
            <%@ include file="/WEB-INF/jsp/web/kor/include/notice.jspf" %>
            <!--//notice-->
        </div>
        <!--//wrap-->
    </form>
</body>
</html>